package cn.ulc.socket.weapp.service.impl;

import cn.ulc.common.exception.PlatformException;
import cn.ulc.socket.weapp.common.BaseService;
import cn.ulc.socket.weapp.service.StaffServ;
import cn.ulc.store.dao.staff.StaffDao;
import cn.ulc.store.entity.staff.Staff;
import cn.ulc.store.entity.user.WeixinUser;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class StaffServImpl extends BaseService implements StaffServ {
    StaffDao staffDao;

    @Override
    public Boolean bindStaff(Long staffId) {
        WeixinUser loginUser = getCurrentUser();
        Staff staff = staffDao.findOne(staffId);
        if(staff==null) throw new PlatformException("获取员工信息失败!");
        staff.setWxUserId(loginUser.getId());
        staffDao.save(staff);
        return true;
    }
}
